package com.iakuil.app.common.core.jsr303.constraints;

import com.iakuil.app.common.core.jsr303.validators.IdsValidatorForArraysOfLong;
import com.iakuil.app.common.core.jsr303.validators.IdsValidatorForCollection;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import jakarta.validation.ReportAsSingleViolation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * ID列表校验注解
 *
 * <p>允许变量值为null，但是不允许列表中出现null元素。
 * <p>BTW. 有时null值也是有业务含义的，此时不要画蛇添足。
 *
 * @author Kai
 * @date 2024-06-14
 */
@Retention(RUNTIME)
@Target(value = {ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
@Constraint(validatedBy = {IdsValidatorForCollection.class, IdsValidatorForArraysOfLong.class})
@ReportAsSingleViolation
public @interface Ids {

    String message() default "ID列表中不允许出现空元素";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
